﻿<UserControl x:Class="Tequila.AugmentedReality.AugmentedRealityControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:Views="clr-namespace:Tequila.AugmentedReality.Views"
             xmlns:Data="clr-namespace:System.Windows.Data;assembly=Tequila.Phone.System.Extensions"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:AugmentedReality="clr-namespace:Tequila.AugmentedReality" mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    x:Name="self"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <Data:BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        </Grid.Resources>

        <Grid x:Name="VideoContainer">
            <Grid.Background>
                <VideoBrush x:Name="CameraView"/>
            </Grid.Background>
        </Grid>

        <ItemsControl x:Name="PoiContainer">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Views:CameraPoiView Visibility="{Binding IsVisible, Converter={StaticResource BoolToVisibilityConverter}}"
                        Data="{Binding }"
                        PoiTemplate="{Binding ElementName=self, Path=POIControlTemplate}"
                        MouseLeftButtonDown="CameraPoiViewTap">

                        <Views:CameraPoiView.RenderTransform>
                            <CompositeTransform TranslateX="{Binding X}"
                                                TranslateY="{Binding Y}"
                                                ScaleX="{Binding Scale}" 
                                                ScaleY="{Binding Scale}"/>
                            
                        </Views:CameraPoiView.RenderTransform>

                        <i:Interaction.Behaviors>
                            <AugmentedReality:ModifyContentPresenterCanvasZIndexBehavior Binding="{Binding ZIndex}"/>
                        </i:Interaction.Behaviors>
                    </Views:CameraPoiView>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

        
    </Grid>
</UserControl>
